# 调压

import serial

ser = None

def init(com_port:str, baud:int):
    global ser
    ser = serial.Serial(com_port, baud)
    return (ser is not None)

def set_volt(voltage: float):
    global ser
    if ser is not None:
        ser.write(f'V{voltage}\r\n'.encode(errors='ignore'))

def close():
    global ser
    if ser is not None:
        ser.close()